var requiredFields = ["firstname", "surname", "email", "username","password","phoneno","address"];

function checkContactForm(myForm) {
  var myForm = document.forms[0];
  for (i in requiredFields) {
    fieldName = requiredFields[i];
    if (!myForm[fieldName].value || myForm[fieldName].value == "Mandatory field") {
      myForm[fieldName].style.color = "#f66";
      myForm[fieldName].value = "Mandatory field";
      var emptyFields = true;
	  var errorMessage = document.getElementById("errormessage").style.color = red;
	  errorMessage.innerHTML = "<p>&#42; Mandatory fields </p>";
    }
  }
  if (!emptyFields) { myForm.submit(); }
}

function resetField(myField) {
  if (myField.value == "Mandatory field") {
    myField.style.color = "#000";
    myField.value = "";

  }
}

